import pylast
import web

urls = (
    '/(.*)', 'hello'
)
app = web.application(urls, globals())



# You have to have your own unique two values for API_KEY and API_SECRET
# Obtain yours from http://www.last.fm/api/account for Last.fm
API_KEY = "bf972f0480e8b3ef94bb27b109c33f84" # this is a sample key
API_SECRET = ""

# In order to perform a write operation you need to authenticate yourself
username = "jollychang"
password_hash = pylast.md5("pass")

network = pylast.get_lastfm_network(api_key = API_KEY, api_secret = API_SECRET, username = username, password_hash = password_hash)

# now you can use that object every where
# artist = network.get_artist("System of a Down")
# artist.shout("<3")


# track = network.get_track("Iron Maiden", "The Nomad")
# track.love()
# track.add_tags("awesome", "favorite")
user =  pylast.User(username, network)
albums = user.get_top_albums(pylast.PERIOD_7DAYS)

for album in albums:
    print album['item']

#todo
class lastfm:
    def GET(self, username, ):
        
    

class hello:        
    def GET(self, name):
        if not name: 
            name = 'World'
        return 'Hello, ' + name + '!'

if __name__ == "__main__":
    app.run()